package com.ibm.spatiotemp.utils;

import java.util.HashMap;

public class SimpleRouter{
	private Queue[] queues = null;
	private HashMap<String, Queue> id2QueueMap;
	private int queueIndex = 0;

	public Queue assignQueue(String modid) {
		Queue queue = id2QueueMap.get(modid);
		if (queue == null) {
			// this is the first time for this table
			queue = queues[queueIndex];
			id2QueueMap.put(modid, queue);
			queueIndex++;
			if (queueIndex == queues.length) {
				queueIndex = 0;
			}
		}
		return queue;
	}

	public void init(Queue[] queueArray) {
		this.queues = queueArray;
		this.id2QueueMap = new HashMap<String, Queue>();
		this.queueIndex = 0;
	}

}
